package com.usian.user.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.user.dtos.UserRelationDto;
import com.usian.model.user.pojos.ApUserFollow;
import com.usian.user.service.UserFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/follow")
public class UserFollowController {
    @Autowired
    private UserFollowService service;
    @PostMapping("/follow/or/cancel")
    public ResponseResult followOrCancel(@RequestBody UserRelationDto dto){
        return service.followOrCancel(dto);
    }

    @GetMapping("get/follow/stauts/{userId}/{followId}")
    public Boolean getResult(@PathVariable Integer userId,@PathVariable Integer followId){
        ApUserFollow follow = service.getOne(Wrappers.<ApUserFollow>lambdaQuery().eq(ApUserFollow::getUserId, userId).eq(ApUserFollow::getFollowId, followId));
        return follow != null;
    }
}
